<template>
	<view class="container">
		<uni-nav-bar fixed statusBar left-icon="left" backgroundColor="#ff9000" :border="false" @clickLeft="back()">
			<!-- <block slot="left">
				<view class="nav-item t-flex-row" @tap.stop="addGoods()">
					<u-icon name="plus-square-fill" color="#fff" size="40"></u-icon>
				</view>
			</block> -->
			<block slot="default">
				<view class="title t-flex-row">
					<view class="t-flex-row notice mp-search-box">
						<input @blur="search()" class="ser-input" type="text" v-model="searchVal"
							placeholder="请输入手机号|用户名" />
					</view>
				</view>
			</block>
		</uni-nav-bar>
		<view v-if="list && list.length > 0" class="box-list">
			<view class="card-box" v-for="(user,index) in list" :key="user.id">
				<!-- <view class="card-box-head u-flex u-col-center">
					<text class="shop-name">{{user.nickname}}</text>
					<text class="order-status">{{shop.status_text}}</text>
				</view> -->
				<view class="card-box-body card-box-body-cloumn">
					<view class="left-img">
						<image mode="aspectFill" :src="user.avatar"></image>
					</view>
					<view class="t-flex-col right-info">
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<!-- <image mode="aspectFill" :src="$IMG_URL + (shop.shop_type == 1 ? '/imgs/freelunch/mt-icon.png' : '/imgs/freelunch/elm-icon.png')">
								</image> -->
								昵称：
							</view>
							<!-- <view class="right-info-box-num">
							名额<text>1</text>/3
						</view> -->
							<view class="right-info-dec">{{user.nickname}}</view>
						</view>
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<!-- <uni-icons style="margin-right: 10rpx;" type="calendar" size="22">
								</uni-icons> -->
								加入时间：
							</view>
							<view class="right-info-box-dec">{{user.jointime_text}}</view>
						</view>
						<view class="t-flex right-info-box right-info-type">
							<view class="right-info-box-icon">
								<!-- <uni-icons style="margin-right: 10rpx;" type="notification" size="22">
								</uni-icons> -->
								手机号码：
							</view>
							<view class="right-info-box-dec">{{user.mobile != '' ? user.mobile:'未设置'}}</view>
						</view>
					</view>
				</view>
				<view class="t-flex card-box-footer u-flex u-col-center">
					<view class="t-flex footer-status">
						<!-- <view class="footer-status-view">
							订单号：<text style="color: #666;" class="footer-status-text">12345678987654465445</text>
						</view> -->

					</view>
					<view class="t-flex footer-btn">
						<button @tap.stop="jump('/pages/shop/admin/shop-list?id='+user.id)"
							class="footer-btn-edit look-shop">查看店铺</button>
						<button v-if="selectId && selectId > 0 && selectId == user.id"
							class="footer-btn-edit footer-btn-admin">管理中</button>
						<button v-else class="footer-btn-edit" @tap.stop="goAdmin(user.id)">进入管理</button>
					</view>
				</view>
			</view>
		</view>
		<uni-load-more :status="loadMore"></uni-load-more>
		<view class="sub">
			<button :loading="requestIng" :disabled="requestIng" @tap.stop="goAdmin(0)">退出管理</button>
			<!-- <button v-else style="background: #eee;">提交成功</button> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				requestIng: false,
				searchVal: '',
				loadMore: 'more',
				page: 1,
				list: []
			};
		},
		onLoad() {
			this.getList();
		},
		methods: {
			jump(url, type = "navigateTo") {
				this.$util.jump(url, type)
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			goAdmin(id) {
				this.$store.dispatch('goAdmin', id);
			},
			async getList() {
				let that = this;
				let requestData = {
					page: that.page
				};
				if (that.searchVal != '') requestData.keyword = that.searchVal;
				that.$util.loading('加载中');
				that.loadMore = 'loading';
				// return new Promise((resolve, reject) => {
				that.$http('user.shareData', requestData).then(async res => {
						console.log('用户列表', res)
						that.requestIng = false
						uni.hideLoading()
						if (res.code === 1) {
							// that.shareSuccess = res.data.totalNum;
							if (requestData.page == 1) {
								that.list = res.data.list
							} else {
								that.list = that.list.concat(res.data.list)
							}
							if (res.data?.length > 0) {
								console.log('页码增加')
								that.page = that.page + 1
							}
							that.loadMore = that.list.length >= res.data.totalNum ? 'no-more' : 'more';
							// resolve(res.data);
						} else {
							that.list = [];
							// resolve(false);
						}
					})
					.catch(async err => {
						that.requestIng = false
						uni.hideLoading()
						// resolve(false);
					})
				// });
			},
			search() {
				if (this.searchVal != '') {
					this.page = 1;
					this.getList();
				}
			}
		}
	}
</script>

<style lang="scss">
	.t-flex {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.t-flex-col {
		@extend .t-flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
	}

	.container {

		// padding-bottom: calc(constant(safe-area-inset-bottom) + 10rpx);
		// padding-bottom: calc(env(safe-area-inset-bottom) + 10rpx);
		.title {
			background: #ff9000;
			// padding: 0 20rpx;
			padding: 0;
			// position: fixed;
			z-index: 999;
			// height: 80rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			width: 80%;

			//正常
			.mp-search-box {
				// position: absolute;
				/* left: 0;
				top: 80rpx;
				z-index: 99;
				width: 100%;
				padding: 0 40rpx;
				background: #ff9000; */
				height: 60rpx;
				background: #fff;
				border-radius: 60rpx;
				width: 100%;

				.ser-input {
					flex: 1;
					// height: 60rpx;
					// line-height: 60rpx;
					text-align: center;
					font-size: 24rpx;
					color: #333;
					// border-radius: 20px;
					// background: #FFFFFF;
					position: relative;
					height: 100%;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					padding: 0 16rpx;
				}

				.search-img {
					position: absolute;
					top: 14rpx;
					left: calc(50% - 90rpx);
					width: 30rpx;
					height: 30rpx;
				}
			}

			/* .notice {
				width: 350rpx;
				// height: 60rpx;
				height: 100%;
				box-sizing: border-box;
				border-radius: 60rpx;
				overflow: hidden;
				// padding: 10rpx 0;
				// margin: 10rpx 0;
				// margin: auto;
				background: red;

				input {
					// height: 60rpx;
					// line-height: 60rpx;
					// height: 100%;
					width: 100%;
				}
			} */
		}

		.box-list {
			// margin: 100rpx 0 0;
			padding-bottom: calc(constant(safe-area-inset-bottom) + 50rpx);
			padding-bottom: calc(env(safe-area-inset-bottom) + 50rpx);
		}

		.card-box {
			width: 94%;
			min-height: 100rpx;
			margin: 30rpx 3%;
			padding: 30rpx 0;
			background: #FFF;
			background-size: 100% 100%;
			box-shadow: 0px 7rpx 11rpx 2rpx rgba(213, 175, 97, 0.34);
			border-radius: 30rpx;
			overflow: hidden;
			position: relative;
			// z-index: 810;


			&-head,
			.card-box-footer {
				color: #000;
				font-size: 30rpx;
				display: flex;
				justify-content: space-between;
				width: 94%;
				margin-left: 3%;
				height: 50rpx;
				align-items: center;
			}

			.shop-name,
			.order-status {
				font-size: 30rpx;
				font-weight: 700;
			}

			.order-status {
				color: #ff9000;
			}

			&-body {
				width: 94%;
				margin: 30rpx 3%;
				display: flex;
				align-items: center;

				.left-img {
					width: 140rpx;
					height: 140rpx;
					border-radius: 20rpx;
					margin-right: 20rpx;
				}

				.right-info {
					font-size: 26rpx;
					color: #999;

					&-box {
						justify-content: flex-start;

						&-icon {
							@extend .t-flex;
							justify-content: center;
							height: 60rpx;
							min-width: 130rpx;
							margin-right: 10rpx;

							image {
								width: 38rpx;
								height: 38rpx;
							}
						}

						.right-info-box-num {
							font-size: 28rpx;
							color: #333;
							font-weight: 600;
							margin-right: 10rpx;

							text {
								color: #FF9000;
							}
						}

						.right-info-dec {
							color: #666;
						}
					}
				}
			}

			.card-box-footer {
				font-size: 28rpx;
				color: #666;

				.footer-status {
					.footer-status-view {
						@extend .t-flex;
						justify-content: flex-start;
						margin-right: 10rpx;

						.footer-status-text {
							color: #ff9000;
						}
					}
				}

				.footer-btn {
					button {
						height: 60rp;
						min-width: 140rpx;
						margin: 0 5rpx;
						border: none;
						background: #ff9000;
						border-radius: 80rpx;
						color: #fff;
						font-size: 26rpx;
					}

					.footer-btn-edit {
						background: #ff9000;
						border: 1px solid #ff9000;
						color: #fff;
					}

					.footer-btn-admin {
						background: #fff;
						color: #ff9000;
						border: none;
						font-size: 32rpx;
						font-weight: 600;
					}

					.look-shop {
						background: #fff;
						border: 1px solid #ff9000;
						color: #ff9000;
					}
				}
			}
		}

		image {
			width: 140rpx;
			height: 140rpx;
			border-radius: 10px;
		}
	}

	.sub {
		position: fixed;
		z-index: 2;
		background: #fff;
		height: 80rpx;
		/* #ifdef H5 */
		left: var(--window-left);
		right: var(--window-right);
		bottom: var(--window-bottom);
		/* #endif */
		/* #ifndef H5 */
		left: 0;
		right: 0;
		bottom: 0;
		/* #endif */
		/* padding: 10rpx 0;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom); */
		padding: 20rpx 0;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);

		button {
			height: 100%;
			margin: 0 10%;
			border: none;
			background: #ff9000;
			border-radius: 80rpx;
			color: #fff;
		}
	}
</style>
